/*
 * EmitirInforme.java
 *
 * Created on Oct 27, 2008, 7:15:42 PM
 */
package wasolicitudesfiec.AperturaTopico;

import com.sun.rave.web.ui.appbase.AbstractPageBean;
import com.sun.rave.web.ui.component.Button;
import com.sun.rave.web.ui.component.DropDown;
import com.sun.rave.web.ui.component.TextArea;
import com.sun.rave.web.ui.model.SingleSelectOptionsList;
import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
import javax.faces.event.ValueChangeEvent;
import wasolicitudesfiec.AperturaTopico.Fragments.FragmentDetalleSolicitarApertura;
import wasolicitudesfiec.SessionBean1;
import wasolicitudesfiec.RequestBean1;
import wasolicitudesfiec.ApplicationBean1;
import wasolicitudesfiec.Menu;
import wasolicitudesfiec.general.MensajeException;
import wasolicitudesfiec.logicacontrol.SolicitarAperturaTopico.CTRL_EmitirInforme;

/**
 * <p>Page bean that corresponds to a similarly named JSP page.  This
 * class contains component definitions (and initialization code) for
 * all components that you have defined on this page, as well as
 * lifecycle methods and event handlers where you may add behavior
 * to respond to incoming events.</p>
 *
 * @author kabad
 */
public class EmitirInforme extends AbstractPageBean {
    // <editor-fold defaultstate="collapsed" desc="Managed Component Definition">

    /**
     * <p>Automatically managed component initialization.  <strong>WARNING:</strong>
     * This method is automatically generated, so any user-specified code inserted
     * here is subject to being replaced.</p>
     */
    private void _init() throws Exception {
        ddlInformeDefaultOptions.setOptions(new com.sun.rave.web.ui.model.Option[]{new com.sun.rave.web.ui.model.Option("Favorable", "Favorable"), new com.sun.rave.web.ui.model.Option("No Favorable", "No Favorable")});
    }
    private TextArea txtaComentarioProfesor = new TextArea();

    public TextArea getTxtaComentarioProfesor() {
        return txtaComentarioProfesor;
    }

    public void setTxtaComentarioProfesor(TextArea ta) {
        this.txtaComentarioProfesor = ta;
    }
    private Button btnEmitirInforme = new Button();

    public Button getBtnEmitirInforme() {
        return btnEmitirInforme;
    }

    public void setBtnEmitirInforme(Button b) {
        this.btnEmitirInforme = b;
    }

    // </editor-fold>
    private CTRL_EmitirInforme cTRL_EmitirInforme;
    private SingleSelectOptionsList ddlInformeDefaultOptions = new SingleSelectOptionsList();

    public SingleSelectOptionsList getDdlInformeDefaultOptions() {
        return ddlInformeDefaultOptions;
    }

    public void setDdlInformeDefaultOptions(SingleSelectOptionsList ssol) {
        this.ddlInformeDefaultOptions = ssol;
    }
    private DropDown ddlInforme = new DropDown();

    public DropDown getDdlInforme() {
        return ddlInforme;
    }

    public void setDdlInforme(DropDown dd) {
        this.ddlInforme = dd;
    }

    /**
     * <p>Construct a new Page bean instance.</p>
     */
    public EmitirInforme() {
        cTRL_EmitirInforme = new CTRL_EmitirInforme(this, this.getFacesContext());
    }

    /**
     * <p>Callback method that is called whenever a page is navigated to,
     * either directly via a URL, or indirectly via page navigation.
     * Customize this method to acquire resources that will be needed
     * for event handlers and lifecycle methods, whether or not this
     * page is performing post back processing.</p>
     * 
     * <p>Note that, if the current request is a postback, the property
     * values of the components do <strong>not</strong> represent any
     * values submitted with this request.  Instead, they represent the
     * property values that were saved for this view when it was rendered.</p>
     */
    @Override
    public void init() {
        try {
            super.init();
            // <editor-fold defaultstate="collapsed" desc="Managed Component Initialization">
            // Initialize automatically managed components
            // *Note* - this logic should NOT be modified
            try {
                _init();
            } catch (Exception e) {
                log("EmitirInforme Initialization Failure", e);
                throw e instanceof FacesException ? (FacesException) e : new FacesException(e);
            }

            // </editor-fold>
            cTRL_EmitirInforme.inicializar();

        } catch (MensajeException ex) {
            cTRL_EmitirInforme.addCookieMensaje(ex.getMessage(),null);
            cTRL_EmitirInforme.redireccionar("/WA_SolicitudesFIEC/faces/general/Mensaje.jsp");
        }
    }

    @Override
    public void preprocess() {
    }

    @Override
    public void prerender() {
    }

    @Override
    public void destroy() {
    }

    protected SessionBean1 getSessionBean1() {
        return (SessionBean1) getBean("SessionBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected RequestBean1 getRequestBean1() {
        return (RequestBean1) getBean("RequestBean1");
    }

    /**
     * <p>Return a reference to the scoped data bean.</p>
     *
     * @return reference to the scoped data bean
     */
    protected ApplicationBean1 getApplicationBean1() {
        return (ApplicationBean1) getBean("ApplicationBean1");
    }

    public Menu getMenu() {
        return (Menu) getBean("SolicitudesFIEC$Menu");
    }

    public FragmentDetalleSolicitarApertura getDetalleSolicitarApertura() {
        return (FragmentDetalleSolicitarApertura) getBean("AperturaTopico$Fragments$FragmentDetalleSolicitarApertura");
    }

    public String btnEmitirInforme_action() {
        FacesMessage message;
        try {
            if (cTRL_EmitirInforme.emitirInforme()) {
                cTRL_EmitirInforme.addCookieMensaje("Su informe ha sido enviado exitosamente",null);
                return "mensaje";
            }
            return null;
        } catch (MensajeException ex) {
            message = new FacesMessage(FacesMessage.SEVERITY_ERROR, ex.getMessage(), ex.getMessage());
            getFacesContext().addMessage(null, message);
            return null;
        }
    }

  
}

